﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public enum EffectMode
{
    Random, //所有效果随机
    Stable, //稳定
}

public enum CameraMode
{
    Normal, //正常
    Paint,//画笔模式
}

[System.Serializable]
public class SettingData
{
    public float _effect_Strengh;   //律动效果强度
    public float _effect_changeDur_max; //效果切换最长时间间隔
    public float _effect_changeDur_min; //
    public float _cameraMode_changeDur_max; //相机clearflag最长间隔
    public float _cameraMode_changeDur_min; //相机clearflag最长间隔

    public float _effect_pathOffsetRadio;   //特效路径偏移幅度

    public EffectMode _effect_mode;
    public CameraMode _cam_mode;

    public int _currentEffectIndex; //当前使用的特效编号
}

public class SettingManager : Singleton<SettingManager> {

    const string key_setting = "key_setting";

    public SettingData _settingData;

    public SettingData DefultSetting
    {
        get {
            SettingData defaultSet = new SettingData();
            defaultSet._effect_mode = EffectMode.Stable;
            defaultSet._cam_mode = CameraMode.Normal;
            defaultSet._currentEffectIndex = 13;
            defaultSet._effect_pathOffsetRadio = 1;
            defaultSet._cameraMode_changeDur_max = 200;
            defaultSet._cameraMode_changeDur_min = 60;
            defaultSet._effect_changeDur_min = 10;
            defaultSet._effect_changeDur_max = 60;
            defaultSet._effect_pathOffsetRadio = 1;
            defaultSet._effect_Strengh = 1;

            return defaultSet;
        }
    }

    public override void Init()
    {
        base.Init();
        LoadSetting();
    }

    public void SaveSetting()
    {
        string str = JsonUtility.ToJson(_settingData);
        PlayerPrefs.SetString(key_setting, str);
    }

    public void LoadSetting()
    {
        string jsonStr = PlayerPrefs.GetString(key_setting);
        _settingData = JsonUtility.FromJson<SettingData>(jsonStr);
        if (_settingData == null)
            _settingData = DefultSetting;
    }

    public override void UnInit()
    {
        base.UnInit();
    }
}
